<template>
  <base-breadcrumb :title="$route.meta.title">
    <!-- 职工代表大会编辑 -->

    <a-spin :spinning="loading">
      <a-form-model ref="ruleForm" :model="form" :label-col="{ span: 6 }" :wrapper-col="{ span: 18 }" :rules="rules">
        <!-- 表格 -->
        <a-card :bordered="false">
          <title-name title="基础信息"></title-name>
          <custom-form :isEmit="false" :formList="formList" :form="form" :editModel="editModel == 0 ? '' : ''" @getProjectInfo="getProjectInfo">
          </custom-form>
        </a-card>
        <a-card :bordered="false">
          <title-name title="设计图纸关联"></title-name>
          <div v-if="editModel != 0">
            关联图纸1：
            <a-button class="mb12" icon="plus" @click="visible = true" :disabled="!form.projectId"></a-button>
          </div>
          <s-table
            :scroll="{ y: 500 }" v-if="form.drawDesignListDTOS.length"
            ref="table"
            size="default"
            rowKey="key"
            :columns="editModel != '0' ? modalColumns : modalColumnsLook"
            :data="loadData"
            :alert="true"
            show-size-changer
            show-quick-jumper
            :showPagination="false"
          >
            <span slot="operation" slot-scope="text, record">
              <span v-if="editModel!=0">
                <a-popconfirm title="确定要删除?" @confirm="() => handleRemove(record)">
                  <a>删除</a>
                </a-popconfirm>
              </span>
            </span>
          </s-table>
        </a-card>
        <a-card :bordered="false" v-if="typess != 'read'">
          <title-name title="审批"></title-name>
          <custom-form :form="form" :formList="auditFormList" :editModel="editModel == 0 ? '' : ''"> </custom-form>
          <Consultation
            :proc-inst-id="procInstId"
            :is-show-btn="$route.query.isMonitoring ? ($route.query.monitoringType==='process' ? true: false): true"
            :task-name="taskName"
            :sub-approver-list.sync="subApproverList"
          >
            <template slot="approverButton">
              <a-button type="primary" :loading="loading.REJECT" @click="handleSave('REJECT')">审批不通过</a-button>
              <a-button type="primary" :loading="loading.PASS" class="ml12" @click="handleSave('PASS')">审批通过</a-button>
            </template>
          </Consultation>
        </a-card>
        <a-card>
          <template>
            <title-name title="审批流程信息" />
            <div class="btns-wrapp mb20">
              <a-button type="primary" @click="visibleState.auditProcess = true"> 审批流程图 </a-button>
            </div>
            <a-spin tip="流程信息加载中..." :spinning="flowRequesting" />
            <a-table :columns="columnApprove" :data-source="approveInfos" bordered>
              <span slot="serial" slot-scope="text, record, index">{{ index + 1 }}</span>
              <template slot="opinions" slot-scope="text">
                <a-tooltip placement="topLeft">
                  <template slot="title">
                    <span> {{ text }}</span>
                  </template>
                  <span> {{ text }}</span>
                </a-tooltip>
              </template>
            </a-table>
          </template>
        </a-card>
        <!-- 页脚操作栏 -->
        <div class="btn_box page-btn-right-top">
          <!-- <a-button v-if="typess == 'read'" type="primary" @click="handleClose">关闭</a-button> -->
          <a-button @click="handleActiveClose">关闭</a-button>
        </div>
      </a-form-model>
    </a-spin>
    <ApprovalDetails
      :title="'审批流程信息'"
      :business-id="id"
      :visible="visibleState.auditProcess"
      @cancel="visibleState.auditProcess = false"
      @confirm="visibleState.auditProcess = false"
    />
    <!-- 表单弹窗 -->
    <!-- <drawing-modal
      ref="drawingModal"
      :form="form"
      keyId="id"
      :visible.sync="visible"
      :searchArr="modalSearchArr"
      :columns="modalColumnsLook"
      @confirm="confirm"
      :api="getDrawDesignList"
      listKey="drawDesignListDTOS"
      :isQuery="true"
    /> -->
  </base-breadcrumb>
</template>

<script>
import { getDrawChange, addDrawChange, updateDrawChange, getDrawDesignList } from '@/api/technical/designFM'
import BaseEditPage from '@/views/baseEditPage' // 编辑详情页基础配置
import SelectSubCompany from '@/components/Select/SelectSubCompany' // 分公司
import SelectProject from '@/components/Select/SelectProject' // 分公司
import UploadList from '@/components/UploadList'
import Selector from '@/components/Select/Selector'
import SelectPersonByProject from '@/components/Select/SelectPersonByProject' // 人员选择
import drawingModal from '../drawingManagement/drawingModal.vue' // 表单弹窗
import { Empty } from 'ant-design-vue'
import ApprovalDetails from '@/components/approvalDetails'
import { messageRead } from '@/api/messageSend'
import { columnApprove } from './model.js'
import { getOrgEmployeesListBy } from '@/api/commons'
import { getProcessNodeList, completeTask } from '@/api/process'
import Consultation from '@/views/matters/approval/components/consultation'
import moment from 'moment'
import Vue from 'vue'
import { majorTypeSelectListTree } from '@/api/technology'
import SelectProjectType from '@/components/Select/SelectProjectType' // 工程类别
const modalSearchArr = [
  {
    name: '专业类别',
    type: Selector,
    valueKey: 'professionalTypeId',
    selectType: '9',
    urlType: 'technical'
  },
  {
    name: '文件名称',
    value: 'name',
    type: 'input'
  },
  {
    name: '文件编号',
    value: 'drawNum',
    type: 'input'
  },
  {
    name: '收文日期',
    type: 'dateRange',
    value: 'callNameDate',
    attr: {
      rangeFormat: ['receiptBeginDate', 'receiptEndDate']
    }
  }
]
const modalColumns = [
  {
    title: '序号',
    width: 80,
    dataIndex: 'index',
    customRender() {
      return arguments[2] + 1
    }
  },
  {
    title: '专业类别',
    dataIndex: 'professionalTypeName'
  },
  {
    title: '工程部位',
    dataIndex: 'projectListName'
  },
  {
    title: '文件名称',
    dataIndex: 'name'
  },
  {
    title: '文件编号',
    dataIndex: 'num'
  },
  {
    title: '版本号',
    dataIndex: 'drawVersion'
  },
  {
    title: '收文日期',
    dataIndex: 'receiptDate'
  },
  {
    title: '操作',
    dataIndex: 'operation',
    width: '230px',
    scopedSlots: { customRender: 'operation' }
  }
]

const modalColumnsLook = [
  {
    title: '专业类别',
    dataIndex: 'professionalTypeName'
  },
  {
    title: '工程部位',
    dataIndex: 'projectListName'
  },
  {
    title: '文件名称',
    dataIndex: 'name'
  },
  {
    title: '文件编号',
    dataIndex: 'num'
  },
  {
    title: '版本号',
    dataIndex: 'drawVersion'
  },
  {
    title: '收文日期',
    dataIndex: 'receiptDate'
  }
]
export default {
  name: 'a' + Date.now(),
  extends: new BaseEditPage(),
  components: {
    drawingModal,
    SelectPersonByProject,
    UploadList,
    Empty,
    ApprovalDetails,
    Consultation
  },
  data() {
    this.modalColumnsLook = modalColumnsLook
    this.modalSearchArr = modalSearchArr
    this.modalColumns = modalColumns
    return {
      projectDeptId: '',
      loading: false, // 加载控件
      visible: false, //弹窗控件
      editModel: 0, // 操作状态:0 查看;1 编辑;2 新增
      disabled: false,
      form: { drawDesignListDTOS: [], projectDeptId: void 0, opinions: '同意' }, // 表单
      getDrawDesignList: getDrawDesignList,
      id: '',
      rules: {
        rework: [{ required: true, message: '请选择' }],
        claim: [{ required: true, message: '请选择' }],
        implementerListDTOS: [{ required: true, message: '请选择' }],
        planBegin: [{ required: true, message: '请选择' }],
        planEnd: [{ required: true, message: '请选择' }],
        opinions: [{ required: true, message: '请输入' }]
        // cc: [{ required: true, message: '请选择' }]
      },
      loadData: () => {
        return new Promise((resolve, reject) => {
          resolve({
            data: this.form.drawDesignListDTOS || []
          })
        })
      },

      init: false, // 初始化控件
      titles: ['设计变更查看', '设计变更编辑', '设计变更新增'],
      //审批相关
      approveInfos: [], // 审批流程信息
      procInstId: '', //当前流程实例ID
      taskId: '', //当前流程节点ID
      processName: '', //流程名称
      taskName: '', //当前流程节点名称
      taskDefKey: '', //任务标识
      currentTime: '', //当前审批时间
      currentUser: '', //当前审批人
      flowRequesting: false,
      detailUrl: null, //详情地址

      assignType: '', //节点类型   0 变量获取 1 处理人 2 候选人 3 候选组 4 会签
      assignCode: '', //候选组编码 岗位编码
      assignLevel: '', //层级 项目部 PD 分公司 BC 公司 CO
      businessType: '', //业务类型 0 项目
      columnApprove,
      visibleState: {
        auditProcess: false
      },
      typess: '',
      loadingBtn: {
        PASS: false,
        REJECT: false
      },
      // 下级审批人
      subApproverList: [],
      listP: []
    }
  },
  props: {
    isAudit: {
      // 是否作为审批详情
      type: Boolean,
      default: false
    }
  },
  watch: {
    isAudit: {
      immediate: true,
      handler(val) {
        if (val) {
          this.$nextTick(() => {
            this.editModel = 0
          })
        }
      }
    }
  },
  mounted() {
    if(this.$route.query.orgin === 'monitoring') {
      this.disabled = true
    }
    this.formattingData() //格式化审批流数据
    this.readMessage()
  },

  computed: {
    formList() {
      return [
        // {
        //   type: SelectSubCompany,
        //   keyName: 'branchComId',
        //   label: '所属分公司',
        //   disabled: true,
        //   attrs: {
        //     isDefaultSelected: this.editModel == 2,
        //     autoSelected: this.editModel == 2
        //   }
        // },
        // {
        //   type: SelectProject,
        //   keyName: 'projectId',
        //   label: '所属项目',
        //   disabled: true,
        //   attrs: {
        //     isDefaultSelected: this.editModel == 2,
        //     autoSelected: this.editModel == 2,
        //     keyValue: 'branchComId',
        //     isClear: this.editModel == 2,
        //     isEdit: this.editModel != 2,
        //     form: this.form
        //   },
        //   selectChange: e => {
        //     this.$set(this.form, 'projectDeptId', e?.projectDeptId)
        //   }
        // },
        {
          label: '所属单位',
          type: 'orgTree',
          keyName: 'projectId',
          span: 16,
          disabled: true,
          isAutoSelectFirst: true,
          isNeedAuth:true ,
          checkStrictly: true,
          viewName: "viewName"
        },
        {
          keyName: 'bigChange',
          disabled: this.editModel == 0,
          type: 'a-radio-group',
          label: '是否重大变更',
          data: [
            {
              label: '是',
              value: 1
            },
            {
              label: '否',
              value: 0
            }
          ]
        },
        // {
        //   keyName: 'professionalTypeId',
        //   label: '专业类别',
        //   type: Selector,
        //   disabled: this.editModel == 0,
        //   attrs: {
        //     selectType: '9',
        //     urlType: 'technical'
        //   }
        // },
        {
          keyName: 'constructionTypeId',
          type: SelectProjectType, 
          disabled: this.editModel == 0,
          label: '工程类别',
          attrs:{
              id:this.form.projectId,
              defaultCheck:this.editModel==2,
              init:false
          },
          change: (val) => {
            this.filtraType(val)
            this.$set(that.form, 'professionalTypeName', '')
            this.$set(that.form, 'professionalTypeId', null)
          },
      },
        {
          keyName: 'professionalTypeId',
          label: '专业类别',
          type: 'ATreeSelect',
          disabled: this.editModel == 0,
          attrs: {
            replaceFields: {children:'children', title:'majorName', key:'id', value: 'id' },
            showSearch: true
          },
          data: this.listP
        },
        {
          type: 'BaseInput',
          label: '设计变更名称',
          disabled: this.editModel == 0,
          keyName: 'name'
        },
        {
          type: 'BaseInput',
          label: '设计变更编号',
          disabled: this.editModel == 0,
          keyName: 'num'
        },
        {
          keyName: 'receiptDate',
          type: 'a-date-picker',
          label: '收文日期',
          disabled: this.editModel == 0,
          attrs: {
            valueFormat: 'YYYY-MM-DD'
          }
        },
        {
          type: 'BaseInput',
          label: '发文部门',
          disabled: this.editModel == 0,
          keyName: 'sendDepartment'
        },

        {
          keyName: 'receiverId',
          type: SelectPersonByProject,
          disabled: this.editModel == 0,
          label: '接收人',
          wrap: true,
          attrs: {
            isOrg: true,
            showSearch: true,
            orgId: this.projectDeptId
          },
          personChanged: e => {
            this.form.receiverName = e?.employeeName
          }
        },
        {
          keyName: 'rework',
          type: 'a-radio-group',
          label: '是否涉及返工',
          disabled: !this.comment,
          hidden: this.typess != 'read',
          data: [
            {
              label: '是',
              value: 1
            },
            {
              label: '否',
              value: 0
            }
          ]
        },
        {
          keyName: 'claim',
          type: 'a-radio-group',
          label: '是否涉及索赔',
          disabled: !this.comment,
          hidden: this.typess != 'read',
          wrap: true,
          data: [
            {
              label: '是',
              value: 1
            },
            {
              label: '否',
              value: 0
            }
          ]
        },
        {
          keyName: 'implementerListDTOS',
          type: SelectPersonByProject,
          label: '主要实施人',
          disabled: true,
          hidden: this.typess != 'read',
          attrs: {
            isOrg: true,
            showSearch: true,
            orgId: this.projectDeptId,
            mode: 'multiple',
            optionLabelProp: 'children'
          }
        },
        {
          keyName: 'planBegin',
          type: 'a-date-picker',
          label: '计划开始时间',
          disabled: true,
          hidden: this.typess != 'read',
          attrs: {
            valueFormat: 'YYYY-MM-DD'
          }
        },
        {
          keyName: 'planEnd',
          type: 'a-date-picker',
          label: '计划完成时间',
          disabled: true,
          hidden: this.typess != 'read',
          attrs: {
            valueFormat: 'YYYY-MM-DD'
          }
        },
        {
          type: 'BaseTextarea',
          label: '内容摘要',
          disabled: this.editModel == 0,
          span: 24,
          keyName: 'options'
        },
        {
          keyName: 'fileInfoVOS',
          type: 'uploadFile',
          disabled: this.editModel == 0,
          label: '附件上传',
          span: 24,
          businessCode: 'BIM03'
        }
      ]
    },
    auditFormList() {
      return [
        {
          keyName: 'rework',
          type: 'a-radio-group',
          label: '是否涉及返工',
          hidden: this.form.bigChange == 1 && this.taskDefKey == 'PD_XMZG_AUDIT',
          disabled: this.disabled,
          data: [
            {
              label: '是',
              value: 1
            },
            {
              label: '否',
              value: 0
            }
          ]
        },
        {
          keyName: 'claim',
          type: 'a-radio-group',
          label: '是否涉及索赔',
          hidden: this.form.bigChange == 1 && this.taskDefKey == 'PD_XMZG_AUDIT',
          disabled: this.disabled,
          wrap: true,
          data: [
            {
              label: '是',
              value: 1
            },
            {
              label: '否',
              value: 0
            }
          ]
        },
        {
          keyName: 'implementerListDTOS',
          type: SelectPersonByProject,
          label: '主要实施人',
          hidden: this.form.bigChange == 1 && this.taskDefKey == 'PD_XMZG_AUDIT',
          disabled: this.disabled,
          attrs: {
            isOrg: true,
            showSearch: true,
            orgId: this.projectDeptId,
            mode: 'multiple',
            optionLabelProp: 'children'
          }
        },
        {
          keyName: 'planBegin',
          type: 'a-date-picker',
          label: '计划开始时间',
          hidden: this.form.bigChange == 1 && this.taskDefKey == 'PD_XMZG_AUDIT',
          disabled: this.disabled,
          attrs: {
            valueFormat: 'YYYY-MM-DD'
          }
        },
        {
          keyName: 'planEnd',
          type: 'a-date-picker',
          label: '计划完成时间',
          hidden: this.form.bigChange == 1 && this.taskDefKey == 'PD_XMZG_AUDIT',
          disabled: this.disabled,
          attrs: {
            valueFormat: 'YYYY-MM-DD'
          }
        },
        {
          keyName: 'opinions',
          type: 'BaseTextarea',
          label: '审批意见',
          disabled: this.disabled,
          span: 24
        },

        {
          keyName: 'taskName',
          type: 'BaseInput',
          label: '当前节点名称',
          disabled: true,

          span: 8
        },
        {
          keyName: 'currentUser',
          type: 'BaseInput',
          label: '审批人',
          disabled: true,

          span: 8
        },
        {
          keyName: 'currentTime',
          type: 'BaseInput',
          label: '审批时间',
          disabled: true,

          span: 8
        },
        {
          keyName: 'durationInMillis',
          type: 'BaseInput',
          label: '当前滞留时间',
          disabled: true,
          span: 8
        },
        {
          keyName: 'cc',
          type: SelectPersonByProject,
          hidden: this.form.bigChange == 1 && this.taskDefKey == 'PD_XMZG_AUDIT',
          disabled: this.disabled,
          label: '抄送人',
          attrs: {
            isOrg: true,
            showSearch: true,
            orgId: this.projectDeptId,
            mode: 'multiple',
            optionLabelProp: 'children'
          }
        }
      ]
    }
  },
  methods: {
    majorTypeSelectListTree() {
      majorTypeSelectListTree(this.form.projectId).then(res=>{
        res.data.forEach(item=>{
          item.majorName = item.programmeName
          item.disabled = true
        })
        this.listP = res.data
        this.initStyle()
        this.$forceUpdate()
      })
    },
    initStyle() {
      try {
        setTimeout(() => {
          const requireDom = document.querySelectorAll('.ant-form-item-required')
          requireDom.forEach(item => {
            item.parentNode.nextSibling.children[0].children[0].classList.add('requiredFormItem') // 找到'.ant-form-item-children'元素添加样式
          })
        }, 0)
      } catch {}
    },
    readMessage() {
      if (!this.detailId) return
      const params = {
        ids: [this.detailId]
      }
      messageRead(params).then(res => {
        if (res && res.data && res.data.code == '200') {
          this.$message.success('查看成功！')
          let count = Number(this.$store.getters['messageInfo/GET_TOREADCOUNT'] - 1)
          this.$store.commit('messageInfo/SET_TOREADCOUNT', count > 0 ? count : 0)
        } else {
          this.$message.error(res.data.message ? res.data.message : '查看失败！')
        }
      })
    },
    formattingData() {
      this.form.user = JSON.parse(sessionStorage.getItem('ycloud-user_info')).username
      this.id = this.$route.query.id
      const {
        type,
        code,
        level,
        btype,
        businessId,
        procInstId,
        name,
        processName,
        detailUrl,
        taskId,
        taskDefKey,
        durationInMillis
      } = this.$route.query
      if (type) {
        this.assignType = type
        this.assignCode = code
        this.assignLevel = level
        this.businessType = btype
      }
      this.id = businessId
      this.detailId = this.$route.query.detailId
      this.typess = this.$route.query.typess
      // this.taskDefKey = 'GS_CWZJBJL_AUDIT'
      if (!this.id) {
        this.$error({ content: '无指定业务ID，将自动关闭' })
        setTimeout(() => {
          window.close()
        }, 1500)
        return
      }
      console.log(this.$route.query)
      this.procInstId = procInstId
      this.form.currentUser = Vue.getAcloudProvider().getUserInfo().name
      this.form.taskName = decodeURIComponent(name)
      this.form.durationInMillis = durationInMillis
      this.processName = decodeURIComponent(processName)
      document.title = this.processName + '-' + this.taskName
      if (detailUrl) {
        this.detailUrl = decodeURIComponent(detailUrl)
      }
      this.taskId = taskId
      this.taskDefKey = taskDefKey

      this.form.currentTime = moment(new Date).format('YYYY-MM-DD HH:mm')
      this.$route.meta.title = '设计变更审批'
      this.getDetails()
      this.getProcessNodes()
    },
    //流程节点信息
    getProcessNodes() {
      this.flowRequesting = true
      getProcessNodeList({ procInstId: this.procInstId, pageNo: 1, pageSize: 100 })
        .then(res => {
          if (res.code === 200) {
            const data = res.data
            const userIds = data.map(d => {
              if (d.formData) {
                d.formData = JSON.parse(d.formData)
              }
              return d.assignee
            })
            getOrgEmployeesListBy({ userIds, delete: true }).then(employees => {
              this.flowRequesting = false
              res.data.forEach(r => {
                employees.data.some(e => {
                  if (e.userId === r.assignee) {
                    r.userName = e.name
                    return true
                  }
                })
              })

              this.approveInfos = res.data
            })
          }
        })
        .catch(() => {
          this.flowRequesting = false
        })
    },
    getDetails() {
      this.loading = true
      console.log(this.id)
      getDrawChange({ id: this.id })
        .then(res => {
          this.loading = false
          res.data.commentDTOS?.forEach(i => {
            i.isEdit = false
          })
          this.form = { ...this.form, ...res.data }
          this.majorTypeSelectListTree()
          this.form.drawDesignListDTOS = this.form.drawDesignListDTOS || []
          if(this.form?.constructionTypeId){
            this.form.constructionTypeId = this.form.constructionTypeId + '';
            this.filtraType(this.form.constructionTypeId);
          }
          this.$refs.table.loadData()
          this.$nextTick(() => {
            this.initStyle()
            this.init = true
          })
        })
        .catch(() => {
          this.loading = false
        })
    },

    /**
     * 提交表单
     */
    validateForm() {
      let flag = false
      this.$refs.ruleForm.validate(e => {
        if (e) {
          flag = true
        }
      })

      return flag
    },
    // 处理增、删、改操作
    handleSave(status) {
      if (this.loadingBtn[status]) return

      if (status == 'PASS') {
        console.log(this.validateForm)
        if (this.validateForm()) {
          this.handelApproval(status)
        }
      } else {
        this.handelUnApproval(status)
      }
    },
    handelApproval(staus) {
      // 审批通过
      const _this = this
      const confirmWin = this.$confirm({
        title: '警告提醒！',
        content: '确定审批通过？',
        okType: 'danger',
        onOk() {
          return new Promise((resolve, reject) => {
            _this
              .submit(false, _this.createApproverList(_this.subApproverList))
              .then(() => {
                resolve()
                confirmWin.destroy()
              })
              .catch(() => reject)
          }).catch(() => this.$error({ content: '审批提交失败，请稍后重试' }))
        },
        onCancel() {}
      })
    },
    notifyParent() {
      window.opener.postMessage('finish', window.location.origin)
    },
    handelUnApproval(staus) {
      // 审批不通过
      const _this = this
      const confirmWin = this.$confirm({
        title: '警告提醒！',
        content: '确定审批不通过？',
        okType: 'danger',
        onOk() {
          return new Promise((resolve, reject) => {
            _this
              .submit(true, staus)
              .then(() => {
                resolve()
                confirmWin.destroy()
              })
              .catch(() => reject)
          }).catch(() => this.$error({ content: '审批提交失败，请稍后重试' }))
        },
        onCancel() {}
      })
    },
    /**
     * @description: 组装下级审批人数据
     * @param {array} subApproverList 下级审批人表格数据
     * @return {object} 下级审批人数据
     */
    createApproverList(subApproverList) {
      const subordinateApproverList = {}
      subApproverList.forEach((item) => {
        if (item?.approver && item.approver.length > 0) {
          subordinateApproverList[item.taskInfo.id] = {
            assgins: item.approver?.map((el) => el.key).join(','),
            assignTypeEnum: 2
          }
        }
      })
      return subordinateApproverList
    },
    async submit(reject) {
      delete this.form.status

      if (reject && this.form.opinions == '同意') {
        this.form.opinions = '不同意'
      } else if (!reject && this.form.opinions == '不同意') {
        this.form.opinions = '同意'
      }
      //判断是否是最后节点
      if (!reject) {
        await updateDrawChange(this.form)
      }

      const data = {
        formData: {
          opinions: this.form.opinions,
          cc: this.form.cc?.join(','),
          content: '设计变更' + (this.form.bigChange == 0 ? '(普通)' : '(重大)') + this.form.name,
          title: '设计变更',
          reject
        },
        procInstId: this.procInstId,
        taskId: this.taskId,
        userId: Vue.getAcloudProvider().getUserInfo().id
      }
      if (reject) {
        data['variables'] = { reject: true }
      }
      return completeTask(data)
        .then(res => {
          if (res.status === 200) {
            this.notifyParent() // 通知父窗口
            // this.$success({
            //   content: '审批提交成功，即将自动关闭当前窗口',
            //   onOk() {
                window.close()
            //   }
            // })
            // setTimeout(() => {
            //   window.close()
            // }, 2000)
          } else {
            this.$error({ content: '审批提交失败，请稍后重试' })
          }
          return res
        })
        .catch(err => {
          return err
        })
    },
    /**
     * @description: 所属单位获取项目信息设置组织id
     * @param {object} info 项目信息
     * @return {void}
     */    
    getProjectInfo(info){
      this.projectDeptId = info?.projectDeptOrgId
      this.form.projectDeptId = info?.projectDeptOrgId
    }
  }
}
</script>

<style lang="less" scoped>
.comments {
  padding: 0 10px 10px 10px;
  position: relative;

  p {
    margin-top: 5px;
  }
  .action {
    position: absolute;
    right: 20px;
    top: 0;
  }
  /deep/ .ant-form-item {
    .ant-form-item-label {
      height: 28px;
      width: 70px;
      line-height: 22px;
      padding: 6px 4px 0 0;
      text-align: right;
      white-space: pre-wrap;
      overflow: visible;
    }
    .ant-form-item-control-wrapper {
      width: calc(100% - 70px);
    }
  }
}
.addcomments {
  /deep/ .ant-form-item {
    .ant-form-item-label {
      height: 28px;
      width: 80px;
      line-height: 22px;
      padding: 6px 4px 0 0;
      text-align: right;
      white-space: pre-wrap;
      overflow: visible;
    }
    .ant-form-item-control-wrapper {
      width: calc(100% - 80px);
    }
  }
}
</style>
